# vim: filetype=yaml sw=2
filename: '[% project %]-[% c("version") %]-[% c("var/build_id") %].tar.gz'
# Note: When updating the gcc version, if this includes a libstdc++
# ABI change we should also update projects/firefox/abicheck.cc to
# require the new version.
version: 9.3.0
var:
  container:
    use_container: 1
  # TODO: Upgrade to a glibc that works out of the box with GCC 8.3.0 (blocked
  # by upgrading Debian to something newer than Wheezy due to the GNU Make
  # dependency).
  glibc_version: 2.26
  glibc_hash: e54e0a934cd2bc94429be79da5e9385898d2306b9eaf3c92d5a77af96190f6bd
  linux_version: 4.10.1
  distdir: gcc
  deps:
    - build-essential
    - libmpc-dev
  setup: |
    mkdir -p /var/tmp/dist
    tar -C /var/tmp/dist -xf $rootdir/[% c("compiler_tarfile") %]
    export PATH="/var/tmp/dist/[% c("var/distdir") %]/bin:$PATH"
    [% IF ! c("var/linux-cross") -%]
      export LD_LIBRARY_PATH=/var/tmp/dist/[% c("var/distdir") %]/lib64:/var/tmp/dist/[% c("var/distdir") %]/lib32
    [% END -%]

    [% IF c("hardened_gcc") -%]
      # Config options for hardening-wrapper
      export DEB_BUILD_HARDENING=1
      export DEB_BUILD_HARDENING_STACKPROTECTOR=1
      export DEB_BUILD_HARDENING_FORTIFY=1
      export DEB_BUILD_HARDENING_FORMAT=1
      export DEB_BUILD_HARDENING_PIE=1

      # Make sure we use the hardening wrapper
      pushd /var/tmp/dist/[% c("var/distdir") %]/bin
      cp /usr/bin/hardened-cc ./
      mv [% c("var/target_prefix") %]gcc [% c("var/target_prefix") %]gcc.real
      mv [% c("var/target_prefix") %]c++ [% c("var/target_prefix") %]c++.real
      mv [% c("var/target_prefix") %]g++ [% c("var/target_prefix") %]g++.real
      ln -sf hardened-cc [% c("var/target_prefix") %]gcc
      ln -sf hardened-cc [% c("var/target_prefix") %]c++
      ln -sf hardened-cc [% c("var/target_prefix") %]g++
      popd
    [% END -%]

targets:
  windows:
    var:
      configure_opt: --disable-multilib --enable-languages=c,c++
      arch_deps:
        - libc6-dev
        - zlib1g-dev
  linux:
    hardened_gcc: 1
    var:
      configure_opt: --enable-multilib --enable-languages=c,c++ --with-arch_32=i686
      arch_deps:
        - hardening-wrapper
        - libc6-dev-i386
  linux-cross:
    var:
      target_prefix: '[% c("var/crosstarget") %]-'
      distdir: gcc-cross
      arch_deps:
        - hardening-wrapper
        - libc6-dev-i386
        - gawk
  linux-arm:
    var:
      configure_opt: --disable-multilib --enable-languages=c,c++ --target=arm-linux-gnueabihf --with-arch=armv7-a --with-fpu=vfpv3-d16 --with-float=hard --with-mode=thumb
  linux-ppc64le:
    var:
      configure_opt: --disable-multilib --enable-languages=c,c++ --target=powerpc64le-linux-gnu --with-cpu=power8 --with-long-double-128
      glibc_version: 2.28
      glibc_hash: b1900051afad76f7a4f73e71413df4826dce085ef8ddb785a945b66d7d513082
      # bison required by glibc 2.28
      arch_deps:
        - hardening-wrapper
        - libc6-dev-i386
        - gawk
        - bison

input_files:
  - project: container-image
  - URL: 'https://ftp.gnu.org/gnu/gcc/gcc-[% c("version") %]/gcc-[% c("version") %].tar.xz'
    sha256sum: 71e197867611f6054aa1119b13a0c0abac12834765fe2d81f35ac57f84f742d1
  - name: binutils
    project: binutils
    enable: '[% c("var/linux-cross") -%]'
  - URL: 'https://ftp.gnu.org/gnu/glibc/glibc-[% c("var/glibc_version") %].tar.xz'
    sha256sum: '[% c("var/glibc_hash") %]'
    enable: '[% c("var/linux-cross") -%]'
  - URL: 'https://www.kernel.org/pub/linux/kernel/v4.x/linux-[% c("var/linux_version") %].tar.xz'
    sha256sum: 6ca06bb5faf5f83600d7388bb623dae41df2a257de85ad5d1792e03302bc3543
    enable: '[% c("var/linux-cross") -%]'
